package com.toune.blackmusic.util;

import com.yanzhenjie.nohttp.NoHttp;
import com.yanzhenjie.nohttp.RequestMethod;
import com.yanzhenjie.nohttp.rest.Request;
import com.yanzhenjie.nohttp.rest.RequestQueue;


/**
 * Created by Administrator on 2018/4/3 0003.
 */

public class RequstUtils {

    public static void GET(String url, NoHttpCallBack noHttpCallBack) {
        GET(url, true, noHttpCallBack);
    }

    public static void GET(String url, boolean isAdd, NoHttpCallBack noHttpCallBack) {
        Request<String> request = NoHttp.createStringRequest(url, RequestMethod.GET);
        RequestQueue queue = MyApplication.getmRequestQueue();
        queue.add(0, request, noHttpCallBack);
    }


    public static void POST(String url, NoHttpCallBack noHttpCallBack) {
        POST(url, true, noHttpCallBack);
    }

    public static void POST(String url, boolean isAdd, NoHttpCallBack noHttpCallBack) {
        RequestQueue requestQueue = MyApplication.getmRequestQueue();
        final Request<String> request = NoHttp.createStringRequest(url,
                RequestMethod.POST);
        request.add(NoHttpCallBack.params);
        /**
         *  what:请求的标识
         *  request：请求
         *  response:请求的回调监听
         */
        requestQueue.add(0, request, noHttpCallBack);
    }


    public static void POSTMUSIC(String url, NoHttpCallBack noHttpCallBack) {
        RequestQueue requestQueue = MyApplication.getmRequestQueue();
        final Request<String> request = NoHttp.createStringRequest(url,
                RequestMethod.POST);
        request.addHeader("X-Requested-With","XMLHttpRequest");
        request.add(NoHttpCallBack.params);
        /**
         *  what:请求的标识
         *  request：请求
         *  response:请求的回调监听
         */
        requestQueue.add(0, request, noHttpCallBack);
    }
}
